package com.bw;

public class NumberUtils {
    //判断字符串参数是否全为数字
    public static boolean isNumber(String str){
        if(str!=null && !str.equals("")){
            String reg_letter="\\d+";
            return str.matches(reg_letter);
        }else{
            return false;
        }
    }
    //判断字符串参数是否全为实数
    public static boolean isShishu(String str){
        if(str!=null && !str.equals("")){
            String reg_letter="^(\\-|\\+)?\\d+(\\.\\d+)?(%)?$";
            return str.matches(reg_letter);
        }else{
            return false;
        }
    }
    //浮点数相加
    public static float add(float str,float str1){
            return str+str1;
    }
    //浮点数相减
    public static float add1(float str,float str1){
        return str-str1;
    }
    //浮点数相乘
    public static float add2(float str,float str1){
        return str*str1;
    }
    //浮点数相除
    public static float add3(float str,float str1){
        return str/str1;
    }
    //浮点数四舍五入
    public static void main(String[] args){
        System.out.println(isNumber("555"));
        System.out.println(isShishu("+123.55"));
        System.out.println(add(1,6));
        System.out.println(add1(1,6));
        System.out.println(add2(1,6));
        System.out.println(add3(1,6));
    }
}
